<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="cn.com.xf.common.Constants"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	List<TblRegVisitor> list = (List<TblRegVisitor>)request.getAttribute("list");
	VisitorForm form = (VisitorForm)request.getAttribute("command");
	String appointtimeStart = StringUtils.isNotBlank(form.getAppointtimeStart())?form.getAppointtimeStart():"";
	String appointtimeEnd = StringUtils.isNotBlank(form.getAppointtimeEnd())?form.getAppointtimeEnd():"";
    String vname = StringUtils.isNotBlank(form.getVname())?form.getVname():"";
    String code = StringUtils.isNotBlank(form.getCode())?form.getCode():"";
	UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
%>

<div class="userListWrap">
    <form id="userListForm">
    	
        <div class="form-item">
    		<label for="vname">预约访客:</label>
    		<input class="easyui-validatebox" type="text" style="width:100px" name="vname" data-options="" value="<%= vname%>"/>
        </div>
       	<div class="form-item form-item-two">
    		<label for="visittime">访问日期:</label>
    		<input id="appointtimeStart" name="appointtimeStart" class="easyui-validatebox" type="text" style="width:100px"  onClick="WdatePicker({errDealMode:1,dateFmt:'yyyy-M-d',minDate:'2017-1-1',maxDate:'%y-%M-%d'})" value="<%= appointtimeStart%>">--
    		<input id="appointtimeEnd" name="appointtimeEnd" class="easyui-validatebox" type="text" style="width:100px"  onClick="WdatePicker({errDealMode:1,dateFmt:'yyyy-M-d',minDate:'2017-1-1',maxDate:'%y-%M-%d'})" value="<%= appointtimeEnd%>">
        </div>
        <input type="hidden" id="staffid" name="staffid" value="<%=user.getEmployId()+"" %>">
        <div class="form-item" style="width:80px">
    		<a href="javascript:XF.Visitor.listAppointSearch()" class="input-btn-microsoft input-btn-microsoft-24">搜索</a>
        </div>        
    </form>
    <table id="appointListTable" class="easyui-datagrid" title="" >
        <thead>
    		<tr>
				<th data-options="field:'vname',width:60">预约访客</th>				
				<th data-options="field:'certtype',width:60">证件类型</th>				
				<th data-options="field:'cert',width:100">证件号码</th>
    			<th data-options="field:'units',width:90">访客单位</th>
    			<th data-options="field:'phone',width:95">联系电话</th>
    			<th data-options="field:'peoplenum',width:40">人数</th>					
				<th data-options="field:'byvisitor',width:60">被访人</th>
				<th data-options="field:'depa',width:80" >被访部门</th>
				<th data-options="field:'aim',width:75" >事由</th>
				<th data-options="field:'appointtime',width:110" >预约时间</th>
				<th data-options="field:'status',width:50" >访客状态</th>
				<th data-options="field:'pro',width:150">操作</th>				
				<th data-options="field:'remark',width:140">备注</th>
				
      		</tr>
        </thead>
        <tbody>
        	<%
        		if(list!=null && list.size() > 0){
        			for(TblRegVisitor visitor:list){
        				%>
       					 <tr s="<%=visitor.getVid() %>"> 					 	      					 	
       					 	<td><i s="<%=visitor.getVid() %>"></i><%=(null!=visitor.getVname())?visitor.getVname()+"":"" %></td>       					 	
       					 	<td><%if(visitor.getCerttype().equals("0")){
       					 			String type = "身份证";%>
       					 			<%=type %>
       					 		<%}else if(visitor.getCerttype().equals("1")){
       					 			String type = "其它";%>
       					 			<%=type %>
       					 		<%}else{
       					 			String type = "";%>
       					 			<%=type %>
       					 		<%}%></td>
       					 	<td><%=(null!=visitor.getCert())?visitor.getCert()+"":"" %></td>
       					 	<td><%=(null!=visitor.getUnits())?visitor.getUnits()+"":"" %></td>
       					 	<td><%=(null!=visitor.getPhone())?visitor.getPhone()+"":"" %></td>
       					 	<td><%=(null!=visitor.getPeoplenum())?visitor.getPeoplenum()+"":"" %></td>
       					 	<td><%=(null!=visitor.getByvisitor())?visitor.getByvisitor()+"":"" %></td>
       					 	<td><%=(null!=visitor.getDepa())?visitor.getDepa()+"":"" %></td>
       					 	<td><%=(null!=visitor.getAim())?visitor.getAim()+"":"" %></td>
       					 	<td><%=null!=visitor.getAppointtime()?DateFormatUtils.format(visitor.getAppointtime().getTime(), "yyyy-MM-dd HH:mm"):"" %></td>
       					 	<td><%if(visitor.getStatus().equals("0")){
       					 			String appstatus = "预约中";%>
       					 			<%=appstatus %>
       					 		<%}else if(visitor.getStatus().equals("1")){
       					 			String appstatus = "访问中";%>
       					 			<%=appstatus %>
       					 		<%}else if(visitor.getStatus().equals("2")){
       					 			String appstatus = "离开";%>
   					 				<%=appstatus %>
       					 		<%}else{
       					 			String appstatus = "";%>
   					 				<%=appstatus %>
       					 		<%}%>
       					 	</td>
       					 	<td>
									<a class="inLink" href="javascript:XF.Visitor.editAppoint('<%=visitor.getVid()+"" %>')"><span>编辑</span></a>
									<a class="inLink" href="javascript:XF.Visitor.deleteAppoint('<%=visitor.getVid()+"" %>')"><span>删除</span></a>
									<%if(visitor.getVaudit().equals("1")){%>
										<a class='auditTab' id="auditTab<%=visitor.getVid()+""%>">已确定</a>
									<%}else{%>
										<a class='auditTab' id="auditTab<%=visitor.getVid()+""%>">未确定</a>
									<%}%>
									<a class="inLink"  href="javascript:XF.Visitor.doVaudit('<%=visitor.getVid()+"" %>')" class="a-btn-microsoft">确定</a>
							</td>
       					 	<td><%=(null!=visitor.getRemark())?visitor.getRemark()+"":"" %></td>				    		
			    		</tr>
        				<%
        			}
        		}
        	%>
    	</tbody>
    </table>
    <div class="pagination paginationFixWidth">
		<monggoTag:pagination 
		href="appoint_search"
		pageSize="<%=form.getPageSize()%>" 
		totalRecord="<%=form.getTotalRecord() %>" 
		currentPage="<%=form.getPageNum() %>">
		</monggoTag:pagination> 
	</div>	
</div>
<script>	
	$('#appointListTable').datagrid();
	<%-- $("#appointtimeStart").datebox({
		formatter:XF.dateFormatter,
		parser:XF.dateParse
	});
	
	<%
	if(StringUtils.isNotBlank(appointtimeStart)){
		%>
			$("#appointtimeStart").datebox("setValue","<%=appointtimeStart%>");
		<%
	}
	%> 

	$("#appointtimeEnd").datebox({
		formatter:XF.dateFormatter,
		parser:XF.dateParse
	});
	
	<%
	if(StringUtils.isNotBlank(appointtimeEnd)){
		%>
			$("#appointtimeEnd").datebox("setValue","<%=appointtimeEnd%>");
		<%
	}
	%>  --%>
</script>



